package db

import (
	"fmt"
	"github.com/lishimeng/app-starter"
)

const (
	RptStatusInit         = 10
	RptStatusSubmit       = 20
	RptStatusProcessing   = 30
	RptStatusGenCompleted = 40
	RptStatusDownloaded   = 50
	RptStatusFail         = 999
	RptStatusClosed       = 90
)

type AmazonRptFile struct {
	RptFileUrl      string `orm:"column(rpt_file_url);null"`
	RptFileSize     int64  `orm:"column(rpt_file_size)"`
	RptFileExpireAt string `orm:"column(rpt_file_expire_at)"`
}

type AmazonRptError struct {
	RptFailureReason string `orm:"column(rpt_failure_reason);null"`
}

type AmazonRptDuration struct {
	StartDate string `orm:"column(start_date)"`
	EndDate   string `orm:"column(end_date)"`
}

type AmazonRpt struct {
	app.Pk
	ClientId      string `orm:"column(client_id)"`
	Name          string `orm:"column(name)"`
	Desc          string `orm:"column(desc);null"`
	RptId         string `orm:"column(rpt_id)"`
	RptTemplateId string `orm:"column(rpt_template_id)"`

	RptState    string `orm:"column(rpt_state)"`
	RptCreateAt string `orm:"column(rpt_create_at)"`
	RptUpdateAt string `orm:"column(rpt_update_at)"`
	Memo        string `orm:"column(memo);null"`
	AmazonRptDuration
	AmazonRptFile
	AmazonRptError
	app.TableChangeInfo
}

func (t *AmazonRpt) TableName() string {
	return "amazon_rpt"
}

func (t *AmazonRpt) GetTempFileName() string {
	return fmt.Sprintf("tmp_%s.json.gz", t.Name)
}
